#include <iostream>
#include <vector>
#include <string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

void Split( vector<string> &vecStr, string strSource, string strSplit)
{
    vector<string>::size_type sPos = 0;
    vector<string>::size_type ePos = strSource.find( strSplit, sPos );
    while( ePos != string::npos )
    {
        if( sPos != ePos ) vecStr.push_back( strSource.substr( sPos, ePos - sPos ) );
        sPos = ePos + strSplit.size();
        ePos = strSource.find( strSplit, sPos );
    }
    if( sPos < strSource.size() ) vecStr.push_back( strSource.substr( sPos, strSource.size() - sPos ) );
}


void testSplitNormal(){
	 string str1 ="name|like bb|wjy";
    vector<string> vecStr;
    Split( vecStr, str1, "|");
    for( vector<string>::iterator iter = vecStr.begin(); iter != vecStr.end(); iter++ )
        cout<<*iter<<endl;	
} 


void testSplitBlank(){
	 string str1 ="weijingyao";
    vector<string> vecStr;
    Split( vecStr, str1, "|");
    for( vector<string>::iterator iter = vecStr.begin(); iter != vecStr.end(); iter++ )
        cout<<*iter<<endl;
	
}
 

int main(int argc, char** argv) {
	
	testSplitNormal();
	
	testSplitBlank();
	
	
	return 0;
}
